function input_click() {
	var backgroundBlur = document.getElementsByClassName('background')[0];
	backgroundBlur.style.width = window.innerWidth + 'px';
	backgroundBlur.style.height = window.innerHeight + 'px';
}

function input_click_out() {
	var backgroundBlur = document.getElementsByClassName('background')[0];
	backgroundBlur.style.width = 0 + 'px';
	backgroundBlur.style.height = 0 + 'px';
}

function IsURL(str_url) {
	if (str_url.indexOf('.') < 0) {
		return false;
	}
	var strRegex = '^((https|http|ftp|rtsp|mms)?://)' +
		'?(([0-9a-z_!~*\'().&=+$%-]+: )?[0-9a-z_!~*\'().&=+$%-]+@)?' //ftp的user@ 
		+
		'(([0-9]{1,3}.){3}[0-9]{1,3}' // IP形式的URL- 199.194.52.184 
		+
		'|' // 允许IP和DOMAIN（域名） 
		+
		'([0-9a-z_!~*\'()-]+.)*' // 域名- www. 
		+
		'([0-9a-z][0-9a-z-]{0,61})?[0-9a-z].' // 二级域名 
		+
		'[a-z]{2,6})' // first level domain- .com or .museum 
		+
		'(:[0-9]{1,4})?' // 端口- :80 
		+
		'((/?)|' // a slash isn't required if there is no file name 
		+
		'(/[0-9a-zA-Z_!~*\'().;?:@&=+$,%#-]+)+/?)$';
	var re = new RegExp(strRegex);
	return re.test(str_url);
}


document.onkeydown = function(event) {
	var e = event || window.event;
	if (e && e.keyCode == 13) { //回车键的键值为13
		var url_str = document.getElementsByClassName("urlInput")[0].value;
		if (IsURL(url_str)) {
			window.location = "http://" + url_str;
		} else {
			window.location = "https://www.baidu.com/s?wd=" + url_str;
		}
		// document.getElementsByClassName("urlInput")[0].style.position = "relative";
		// var i = 0;
		document.getElementsByClassName("urlInput")[0].style.marginTop = 40 + "px";
		document.activeElement = document.body;
		// setInterval(function() {
		// 	document.getElementsByClassName("urlInput")[0].style.top = i + "px";
		// 	i += 50;
		// }, 10);
	}
};
